#include <iostream>
using namespace std;
char map[9][9];
bool arr;
int n,m;
void dfs(int t,int nowt,int a,int b)
{
    if (nowt<t && arr==false)
    {
        if (a+1<n)
        {
            if (map[a+1][b]=='D' && nowt==t-1)arr=true;
            else if (map[a+1][b]=='.')
            {
                map[a+1][b]='X';
                dfs(t,nowt+1,a+1,b);
                map[a+1][b]='.';
            }
        }
        if (b+1<m)
        {
            if (map[a][b+1]=='D' && nowt==t-1)arr=true;
            else if (map[a][b+1]=='.')
            {
                map[a][b+1]='X';
                dfs(t,nowt+1,a,b+1);
                map[a][b+1]='.';
            }
        }
        if (a-1>=0)
        {
            if (map[a-1][b]=='D' && nowt==t-1)arr=true;
            else if (map[a-1][b]=='.')
            {
                map[a-1][b]='X';
                dfs(t,nowt+1,a-1,b);
                map[a-1][b]='.';
            }
        }
        if (b-1>=0)
        {
            if (map[a][b-1]=='D' && nowt==t-1)arr=true;
            else if (map[a][b-1]=='.')
            {
                map[a][b-1]='X';
                dfs(t,nowt+1,a,b-1);
                map[a][b-1]='.';
            }
        }
    }
}
int main()
{
    int t;
    while (cin>>n>>m>>t)
    {
        if (n==0 && m==0 && t==0)break;
        int i,j,x,y;
        for (i=0;i<n;i++)
        {
            cin>>map[i];
            for (j=0;j<m;j++)
            {
                if (map[i][j]=='S')
                {
                    x=i;
                    y=j;
                }
            }
        }
        map[x][y]='X';
        arr=false;
        dfs(t,0,x,y);
        if (arr) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}